import { BaseResponseData } from "@renderer/interface/baseData";
import { IResponseData, IUserData, IUserListRes, IUsersList, PostPageResponse, Unit, UserGetResponse } from "@renderer/interface/user";
import http from "@renderer/utils/request";

// 用户信息
export const getInfo = () => http.get<IUserData>('/personal/getInfo')
// 用户路由权限
export const getMenu = (rolePerm) => http.get<IResponseData>(`/personal/getRouters/${rolePerm}`)
/* 用户列表 */
export const getUserPageApi = (data: IUsersList) => http.get<IUserListRes>('/system/user/page', data)
/**
 * 添加/修改用户
 * @param data 
 * @returns 
 */
export const postUserAOUApi = (data) => http.post<BaseResponseData<string>>('/system/user/' + `${data.id ? 'update' : 'add'}`, data)
/**
 * 用户详情
 * @param id 用户id
 * @returns 用户详情
 */
export const getUserGetApi = (id: string) => http.get<UserGetResponse>(`/system/user/get/${id}`)
/**
 * 机构列表
 * @returns 
 */
export const getUnitListApi = () => http.get<BaseResponseData<Unit[]>>('/system/unit/list')
/**
 * 岗位列表
 * @returns 
 */
export const getPostPageApi = () => http.get<PostPageResponse>('/system/post/page')
/**
 * 根据id删除用户
 * @param id 用户id
 * @returns 
 */
export const getUserDeleteApi = (id: string) => http.get<BaseResponseData<string>>(`/system/user/delete/${id}`)